<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Lehmer code</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Lehmer_code"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Lehmer_code rootpage-Lehmer_code skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Lehmer code</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>In <a href="Mathematics" title="Mathematics">mathematics</a> and in particular in <a href="Combinatorics" title="Combinatorics">combinatorics</a>, the <b>Lehmer code</b> is a particular way to <a href="Encoding" class="mw-redirect" title="Encoding">encode</a> each possible <a href="Permutation" title="Permutation">permutation</a> of a sequence of <i>n</i> numbers. It is an instance of a scheme for <a href="Permutation#Numbering_permutations" title="Permutation">numbering permutations</a> and is an example of an <a href="Inversion_(discrete_mathematics)" title="Inversion (discrete mathematics)">inversion</a> table.
</p><p>The Lehmer code is named in reference to <a href="D._H._Lehmer" title="D. H. Lehmer">D. H. Lehmer</a>,<sup id="cite_ref-lehmer_1-0" class="reference"><a href="#cite_note-lehmer-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> but the code had been known since 1888 at least.<sup id="cite_ref-laisant_2-0" class="reference"><a href="#cite_note-laisant-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="The_code">The code</h2></div>
<p>The Lehmer code makes use of the fact that there are
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n!=n\times (n-1)\times \cdots \times 2\times 1}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
<mo>!</mo>
<mo>=</mo>
<mi>n</mi>
<mo>×<!-- × --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo>×<!-- × --></mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>×<!-- × --></mo>
<mn>2</mn>
<mo>×<!-- × --></mo>
<mn>1</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n!=n\times (n-1)\times \cdots \times 2\times 1}</annotation>
</semantics>
</math></span><img src="./0f6f869ce2d8e2880651f1c8778f1aaab9e10e79.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:30.151ex; height:2.843ex;" alt="{\displaystyle n!=n\times (n-1)\times \cdots \times 2\times 1}" loading="lazy"></span></dd></dl>
<p>permutations of a sequence of <i>n</i> numbers. If a permutation <i>σ</i> is specified by the sequence (<i>σ</i><sub>1</sub>, ..., <i>σ<sub>n</sub></i>) of its images of 1, ..., <i>n</i>, then it is encoded by a sequence of <i>n</i> numbers, but not all such sequences are valid since every number must be used only once. By contrast the encodings considered here choose the first number from a set of <i>n</i> values, the next number from a fixed set of <span class="texhtml"><i>n</i> − 1</span> values, and so forth decreasing the number of possibilities until the last number for which only a single fixed value is allowed; <i>every</i> sequence of numbers chosen from these sets encodes a single permutation. While several <a href="Encoding" class="mw-redirect" title="Encoding">encodings</a> can be defined, the Lehmer code has several additional useful properties; it is the sequence
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle L(\sigma )=(L(\sigma )_{1},\ldots ,L(\sigma )_{n})\quad {\text{where}}\quad L(\sigma )_{i}=\#\{j>i:\sigma _{j}<\sigma _{i}\},}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>σ<!-- σ --></mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo stretchy="false">(</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>σ<!-- σ --></mi>
<msub>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>σ<!-- σ --></mi>
<msub>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mspace width="1em"></mspace>
<mrow class="MJX-TeXAtom-ORD">
<mtext>where</mtext>
</mrow>
<mspace width="1em"></mspace>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>σ<!-- σ --></mi>
<msub>
<mo stretchy="false">)</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo>=</mo>
<mi mathvariant="normal">#<!-- # --></mi>
<mo fence="false" stretchy="false">{</mo>
<mi>j</mi>
<mo>></mo>
<mi>i</mi>
<mo>:</mo>
<msub>
<mi>σ<!-- σ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>j</mi>
</mrow>
</msub>
<mo><</mo>
<msub>
<mi>σ<!-- σ --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>i</mi>
</mrow>
</msub>
<mo fence="false" stretchy="false">}</mo>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle L(\sigma )=(L(\sigma )_{1},\ldots ,L(\sigma )_{n})\quad {\text{where}}\quad L(\sigma )_{i}=\#\{j>i:\sigma _{j}<\sigma _{i}\},}</annotation>
</semantics>
</math></span><img src="./30ea837af6169090dcaa7e428a852d7c8541e377.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:64.903ex; height:3.009ex;" alt="{\displaystyle L(\sigma )=(L(\sigma )_{1},\ldots ,L(\sigma )_{n})\quad {\text{where}}\quad L(\sigma )_{i}=\#\{j>i:\sigma _{j}<\sigma _{i}\},}" loading="lazy"></span></dd></dl>
<p>in other words the term <i>L</i>(<i>σ</i>)<sub><i>i</i></sub> counts the number of terms in (<i>σ</i><sub>1</sub>, ..., <i>σ<sub>n</sub></i>) to the right of <i>σ<sub>i</sub></i> that are smaller than it, a number between 0 and <span class="texhtml"><i>n</i> − <i>i</i></span>, allowing for <span class="texhtml"><i>n</i> + 1 − <i>i</i></span> different values.
</p><p>A pair of indices (<i>i</i>,<i>j</i>) with <span class="texhtml"><i>i</i> < <i>j</i></span> and <span class="texhtml"><i>σ<sub>i</sub></i> > <i>σ<sub>j</sub></i></span> is called an inversion of <i>σ</i>, and <i>L</i>(<i>σ</i>)<sub><i>i</i></sub> counts the number of inversions (<i>i</i>,<i>j</i>) with <i>i</i> fixed and varying <i>j</i>. It follows that <span class="texhtml"><i>L</i>(<i>σ</i>)<sub>1</sub> + <i>L</i>(<i>σ</i>)<sub>2</sub> + … + <i>L</i>(<i>σ</i>)<sub><i>n</i></sub></span> is the total number of inversions of <i>σ</i>, which is also the number of adjacent transpositions that are needed to transform the permutation into the identity permutation. Other properties of the Lehmer code include that the <a href="Lexicographical_order" class="mw-redirect" title="Lexicographical order">lexicographical order</a> of the encodings of two permutations is the same as that of their sequences (<i>σ</i><sub>1</sub>, ..., <i>σ<sub>n</sub></i>), that any value 0 in the code represents a right-to-left minimum in the permutation (i.e., a <span class="texhtml"><i>σ<sub>i</sub></i></span> smaller than any <span class="texhtml"><i>σ<sub>j</sub></i></span> to its right), and a value <span class="texhtml"><i>n</i> − <i>i</i></span>
at position <i>i</i> similarly signifies a right-to-left maximum, and that the Lehmer code of <i>σ</i> coincides with the <a href="Factorial_number_system" title="Factorial number system">factorial number system</a> representation of its position in the list of permutations of <i>n</i> in lexicographical order (numbering the positions starting from 0).
</p><p>Variations of this encoding can be obtained by counting inversions (<i>i</i>,<i>j</i>) for fixed <i>j</i> rather than fixed <i>i</i>, by counting inversions with a fixed smaller <i>value</i> <span class="texhtml"><i>σ<sub>j</sub></i></span> rather than smaller index <i>i</i>, or by counting non-inversions rather than inversions; while this does not produce a fundamentally different type of encoding, some properties of the encoding will change correspondingly. In particular counting inversions with a fixed smaller value <span class="texhtml"><i>σ<sub>j</sub></i></span> gives the inversion table of <i>σ</i>, which can be seen to be the Lehmer code of the inverse permutation.
</p>
<div class="mw-heading mw-heading2"><h2 id="Encoding_and_decoding">Encoding and decoding</h2></div>
<p>The usual way to prove that there are <i>n</i>! different permutations of <i>n</i> objects is to observe that the first object can be chosen in <span class="texhtml"><i>n</i></span> different ways, the next object in <span class="texhtml"><i>n</i> − 1</span> different ways (because choosing the same number as the first is forbidden), the next in <span class="texhtml"><i>n</i> − 2</span> different ways (because there are now 2 forbidden values), and so forth. Translating this freedom of choice at each step into a number, one obtains an encoding algorithm, one that finds the Lehmer code of a given permutation. One need not suppose the objects permuted to be numbers, but one needs a <a href="Total_ordering" class="mw-redirect" title="Total ordering">total ordering</a> of the set of objects. Since the code numbers are to start from 0, the appropriate number to encode each object <i>σ<sub>i</sub></i> by is the number of objects that were available at that point (so they do not occur before position <i>i</i>), but which are smaller than the object <i>σ<sub>i</sub></i> actually chosen. (Inevitably such objects must appear at some position <span class="texhtml"><i>j</i> > <i>i</i></span>, and (<i>i</i>,<i>j</i>) will be an inversion, which shows that this number is indeed <i>L</i>(<i>σ</i>)<sub><i>i</i></sub>.)
</p><p>This number to encode each object can be found by direct counting, in several ways (directly counting inversions, or correcting the total number of objects smaller than a given one, which is its sequence number starting from 0 in the set, by those that are unavailable at its position). Another method which is in-place, but not really more efficient, is to start with the permutation of {0, 1, ... <span class="texhtml"><i>n</i> − 1</span>} obtained by representing each object by its mentioned sequence number, and then for each entry <i>x</i>, in order from left to right, correct the items to its right by subtracting 1 from all entries (still) greater than <i>x</i> (to reflect the fact that the object corresponding to <i>x</i> is no longer available). Concretely a Lehmer code for the permutation B,F,A,G,D,E,C of letters, ordered alphabetically, would first give the list of sequence numbers 1,5,0,6,3,4,2, which is successively transformed
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle {\begin{matrix}\mathbf {1} &5&0&6&3&4&2\\1&\mathbf {4} &0&5&2&3&1\\1&4&\mathbf {0} &4&2&3&1\\1&4&0&\mathbf {3} &1&2&0\\1&4&0&3&\mathbf {1} &2&0\\1&4&0&3&1&\mathbf {1} &0\\1&4&0&3&1&1&\mathbf {0} \\\end{matrix}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mtable rowspacing="4pt" columnspacing="1em">
<mtr>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">1</mn>
</mrow>
</mtd>
<mtd>
<mn>5</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mn>6</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">4</mn>
</mrow>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mn>5</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">0</mn>
</mrow>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">3</mn>
</mrow>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">1</mn>
</mrow>
</mtd>
<mtd>
<mn>2</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">1</mn>
</mrow>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
</mtr>
<mtr>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>4</mn>
</mtd>
<mtd>
<mn>0</mn>
</mtd>
<mtd>
<mn>3</mn>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mn>1</mn>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mn mathvariant="bold">0</mn>
</mrow>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle {\begin{matrix}\mathbf {1} &5&0&6&3&4&2\\1&\mathbf {4} &0&5&2&3&1\\1&4&\mathbf {0} &4&2&3&1\\1&4&0&\mathbf {3} &1&2&0\\1&4&0&3&\mathbf {1} &2&0\\1&4&0&3&1&\mathbf {1} &0\\1&4&0&3&1&1&\mathbf {0} \\\end{matrix}}}</annotation>
</semantics>
</math></span><img src="./22a33e7dfbddbb2034edb8748c20bb7a7ffbbf77.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -10.671ex; width:24.044ex; height:22.343ex;" alt="{\displaystyle {\begin{matrix}\mathbf {1} &5&0&6&3&4&2\\1&\mathbf {4} &0&5&2&3&1\\1&4&\mathbf {0} &4&2&3&1\\1&4&0&\mathbf {3} &1&2&0\\1&4&0&3&\mathbf {1} &2&0\\1&4&0&3&1&\mathbf {1} &0\\1&4&0&3&1&1&\mathbf {0} \\\end{matrix}}}" loading="lazy"></span></dd></dl>
<p>where the final line is the Lehmer code (at each line one subtracts 1 from the larger entries to the right of the boldface element to form the next line).
</p><p>For decoding a Lehmer code into a permutation of a given set, the latter procedure may be reversed: for each entry <i>x</i>, in order from right to left, correct the items to its right by adding 1 to all those (currently) greater than or equal to <i>x</i>; finally interpret the resulting permutation of {0, 1, ... <span class="texhtml"><i>n</i> − 1</span>} as sequence numbers (which amounts to adding 1 to each entry if a permutation of {1, 2, ... <i>n</i>} is sought). Alternatively the entries of the Lehmer code can be processed from left to right, and interpreted as a number determining the next choice of an element as indicated above; this requires maintaining a list of available elements, from which each chosen element is removed. In the example this would mean choosing element 1 from {A,B,C,D,E,F,G} (which is B) then element 4 from {A,C,D,E,F,G} (which is F), then element 0 from {A,C,D,E,G} (giving A) and so on, reconstructing the sequence B,F,A,G,D,E,C.
</p>
<div class="mw-heading mw-heading2"><h2 id="Applications_to_combinatorics_and_probabilities">Applications to combinatorics and probabilities</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Independence_of_relative_ranks">Independence of relative ranks</h3></div>
<p>The Lehmer code defines a bijection from the <a href="Symmetric_group" title="Symmetric group">symmetric group</a> <i>S<sub>n</sub></i> to the Cartesian product <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle [n]\times [n-1]\times \cdots \times [2]\times [1]}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo stretchy="false">[</mo>
<mi>n</mi>
<mo stretchy="false">]</mo>
<mo>×<!-- × --></mo>
<mo stretchy="false">[</mo>
<mi>n</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo stretchy="false">]</mo>
<mo>×<!-- × --></mo>
<mo>⋯<!-- ⋯ --></mo>
<mo>×<!-- × --></mo>
<mo stretchy="false">[</mo>
<mn>2</mn>
<mo stretchy="false">]</mo>
<mo>×<!-- × --></mo>
<mo stretchy="false">[</mo>
<mn>1</mn>
<mo stretchy="false">]</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle [n]\times [n-1]\times \cdots \times [2]\times [1]}</annotation>
</semantics>
</math></span><img src="./e9083866075373cd9c8bebc725636b5d3fa667e4.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:28.377ex; height:2.843ex;" alt="{\displaystyle [n]\times [n-1]\times \cdots \times [2]\times [1]}" loading="lazy"></span>, where [<i>k</i>] designates the <i>k</i>-element set <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{0,1,\ldots ,k-1\}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mn>0</mn>
<mo>,</mo>
<mn>1</mn>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo fence="false" stretchy="false">}</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{0,1,\ldots ,k-1\}}</annotation>
</semantics>
</math></span><img src="./f3269d4d896f77d7be6e47d0cc35f54acdd15f98.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:16.076ex; height:2.843ex;" alt="{\displaystyle \{0,1,\ldots ,k-1\}}" loading="lazy"></span>. As a consequence, under the <a href="Uniform_distribution_(discrete)" class="mw-redirect" title="Uniform distribution (discrete)">uniform distribution</a> on <i>S<sub>n</sub></i>, the component <i>L</i>(<i>σ</i>)<sub><i>i</i></sub> defines a uniformly distributed <a href="Random_variable" title="Random variable">random variable</a> on <span class="texhtml">[<i>n</i> − <i>i</i>]</span>, and these random variables are mutually <a href="Independence_(probability_theory)" title="Independence (probability theory)">independent</a>, because they are projections on different factors of a <a href="Cartesian_product" title="Cartesian product">Cartesian product</a>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Number_of_right-to-left_minima_and_maxima">Number of right-to-left minima and maxima</h3></div>
<p>Definition : In a sequence <i>u=(u<sub>k</sub>)<sub>1≤k≤n</sub></i>, there is <b>right-to-left minimum</b> (resp. <b>maximum</b>) at rank <i>k</i> if <i>u<sub>k</sub></i> is strictly smaller (resp. strictly bigger) than each element <i>u<sub>i</sub></i> with <i>i>k</i>, i.e., to its right.
</p><p>Let <i>B(k)</i> (resp. <i>H(k)</i>) be the event "there is right-to-left minimum (resp. maximum) at rank <i>k</i>", i.e. <i>B(k)</i> is the set of the permutations <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \scriptstyle \ {\mathfrak {S}}_{n}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mstyle displaystyle="false" scriptlevel="1">
<mtext> </mtext>
<msub>
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="fraktur">S</mi>
</mrow>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</msub>
</mstyle>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \scriptstyle \ {\mathfrak {S}}_{n}}</annotation>
</semantics>
</math></span><img src="./f52258ea58e3cb34d89e5a0206a267d0a13ce4c8.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:2.908ex; height:1.843ex;" alt="{\displaystyle \scriptstyle \ {\mathfrak {S}}_{n}}" loading="lazy"></span> which exhibit a right-to-left minimum (resp. maximum) at rank <i>k</i>. We clearly have
</p>
<div class="center"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \{\omega \in B(k)\}\Leftrightarrow \{L(k,\omega )=0\}\quad {\text{and}}\quad \{\omega \in H(k)\}\Leftrightarrow \{L(k,\omega )=k-1\}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo fence="false" stretchy="false">{</mo>
<mi>ω<!-- ω --></mi>
<mo>∈<!-- ∈ --></mo>
<mi>B</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo fence="false" stretchy="false">}</mo>
<mo stretchy="false">⇔<!-- ⇔ --></mo>
<mo fence="false" stretchy="false">{</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo>,</mo>
<mi>ω<!-- ω --></mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mn>0</mn>
<mo fence="false" stretchy="false">}</mo>
<mspace width="1em"></mspace>
<mrow class="MJX-TeXAtom-ORD">
<mtext>and</mtext>
</mrow>
<mspace width="1em"></mspace>
<mo fence="false" stretchy="false">{</mo>
<mi>ω<!-- ω --></mi>
<mo>∈<!-- ∈ --></mo>
<mi>H</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo fence="false" stretchy="false">}</mo>
<mo stretchy="false">⇔<!-- ⇔ --></mo>
<mo fence="false" stretchy="false">{</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo>,</mo>
<mi>ω<!-- ω --></mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo fence="false" stretchy="false">}</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \{\omega \in B(k)\}\Leftrightarrow \{L(k,\omega )=0\}\quad {\text{and}}\quad \{\omega \in H(k)\}\Leftrightarrow \{L(k,\omega )=k-1\}.}</annotation>
</semantics>
</math></span><img src="./6f2a0f206aaaa2c5ddb2dee402496b498d73cb58.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:70.749ex; height:2.843ex;" alt="{\displaystyle \{\omega \in B(k)\}\Leftrightarrow \{L(k,\omega )=0\}\quad {\text{and}}\quad \{\omega \in H(k)\}\Leftrightarrow \{L(k,\omega )=k-1\}.}" loading="lazy"></span></div>
<p>Thus the number <i>N<sub>b</sub>(ω)</i> (resp. <i>N<sub>h</sub>(ω)</i>) of right-to-left minimum (resp. maximum) for the permutation <i>ω</i> can be written as a sum of independent <a href="Bernoulli_random_variable" class="mw-redirect" title="Bernoulli random variable">Bernoulli random variables</a> each with a respective parameter of 1/k :
</p>
<div class="center"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{B(k)}\quad {\text{and}}\quad N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{H(k)}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>N</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>b</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>ω<!-- ω --></mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
<mo>≤<!-- ≤ --></mo>
<mi>k</mi>
<mo>≤<!-- ≤ --></mo>
<mi>n</mi>
</mrow>
</munder>
<mtext> </mtext>
<mn>1</mn>
<mspace width="negativethinmathspace"></mspace>
<mspace width="negativethinmathspace"></mspace>
<msub>
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mi>B</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mrow>
</msub>
<mspace width="1em"></mspace>
<mrow class="MJX-TeXAtom-ORD">
<mtext>and</mtext>
</mrow>
<mspace width="1em"></mspace>
<msub>
<mi>N</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>b</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>ω<!-- ω --></mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<munder>
<mo>∑<!-- ∑ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
<mo>≤<!-- ≤ --></mo>
<mi>k</mi>
<mo>≤<!-- ≤ --></mo>
<mi>n</mi>
</mrow>
</munder>
<mtext> </mtext>
<mn>1</mn>
<mspace width="negativethinmathspace"></mspace>
<mspace width="negativethinmathspace"></mspace>
<msub>
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mi>H</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mrow>
</msub>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{B(k)}\quad {\text{and}}\quad N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{H(k)}.}</annotation>
</semantics>
</math></span><img src="./c6cf58e2ce486fed1f700436af5ae029292cc456.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.338ex; width:50.277ex; height:5.843ex;" alt="{\displaystyle N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{B(k)}\quad {\text{and}}\quad N_{b}(\omega )=\sum _{1\leq k\leq n}\ 1\!\!1_{H(k)}.}" loading="lazy"></span></div>
<p>Indeed, as <i>L(k)</i> follows the uniform law on <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \scriptstyle \ [\![1,k]\!],}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mstyle displaystyle="false" scriptlevel="1">
<mtext> </mtext>
<mo stretchy="false">[</mo>
<mspace width="negativethinmathspace"></mspace>
<mo stretchy="false">[</mo>
<mn>1</mn>
<mo>,</mo>
<mi>k</mi>
<mo stretchy="false">]</mo>
<mspace width="negativethinmathspace"></mspace>
<mo stretchy="false">]</mo>
<mo>,</mo>
</mstyle>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \scriptstyle \ [\![1,k]\!],}</annotation>
</semantics>
</math></span><img src="./634ca8608aae56d85a27e44a6215624d61bb3e2e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:4.229ex; height:2.176ex;" alt="{\displaystyle \scriptstyle \ [\![1,k]\!],}" loading="lazy"></span>
</p>
<div class="center"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbb {P} (B(k))=\mathbb {P} (L(k)=0)=\mathbb {P} (H(k))=\mathbb {P} (L(k)=k-1)={\tfrac {1}{k}}.}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">P</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>B</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">P</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">P</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>H</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi mathvariant="double-struck">P</mi>
</mrow>
<mo stretchy="false">(</mo>
<mi>L</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="false" scriptlevel="0">
<mfrac>
<mn>1</mn>
<mi>k</mi>
</mfrac>
</mstyle>
</mrow>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \mathbb {P} (B(k))=\mathbb {P} (L(k)=0)=\mathbb {P} (H(k))=\mathbb {P} (L(k)=k-1)={\tfrac {1}{k}}.}</annotation>
</semantics>
</math></span><img src="./2708d4893d1d4bb9c2334ece0324f4452e8b458a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.338ex; width:59.3ex; height:3.676ex;" alt="{\displaystyle \mathbb {P} (B(k))=\mathbb {P} (L(k)=0)=\mathbb {P} (H(k))=\mathbb {P} (L(k)=k-1)={\tfrac {1}{k}}.}" loading="lazy"></span></div>
<p>The <a href="Generating_function" title="Generating function">generating function</a> for the Bernoulli random variable <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 1\!\!1_{B(k)}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>1</mn>
<mspace width="negativethinmathspace"></mspace>
<mspace width="negativethinmathspace"></mspace>
<msub>
<mn>1</mn>
<mrow class="MJX-TeXAtom-ORD">
<mi>B</mi>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 1\!\!1_{B(k)}}</annotation>
</semantics>
</math></span><img src="./bca752cb4e501b29b95e230cd652274c7ec4cd6f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.171ex; width:5.166ex; height:3.009ex;" alt="{\displaystyle 1\!\!1_{B(k)}}" loading="lazy"></span> is
</p>
<div class="center"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle G_{k}(s)={\frac {k-1+s}{k}},}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>G</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>s</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo>+</mo>
<mi>s</mi>
</mrow>
<mi>k</mi>
</mfrac>
</mrow>
<mo>,</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle G_{k}(s)={\frac {k-1+s}{k}},}</annotation>
</semantics>
</math></span><img src="./98f39ae02534b5fbfdcbf4cdf6e3f8f1b29a1de9.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -2.005ex; width:19.542ex; height:5.509ex;" alt="{\displaystyle G_{k}(s)={\frac {k-1+s}{k}},}" loading="lazy"></span></div>
<p>therefore the generating function of <i>N<sub>b</sub></i> is
</p>
<div class="center"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle G(s)=\prod _{k=1}^{n}G_{k}(s)\ =\ {\frac {s^{\overline {n}}}{n!}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>G</mi>
<mo stretchy="false">(</mo>
<mi>s</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<munderover>
<mo>∏<!-- ∏ --></mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
<mo>=</mo>
<mn>1</mn>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</munderover>
<msub>
<mi>G</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>k</mi>
</mrow>
</msub>
<mo stretchy="false">(</mo>
<mi>s</mi>
<mo stretchy="false">)</mo>
<mtext> </mtext>
<mo>=</mo>
<mtext> </mtext>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<msup>
<mi>s</mi>
<mrow class="MJX-TeXAtom-ORD">
<mover>
<mi>n</mi>
<mo accent="false">¯<!-- ¯ --></mo>
</mover>
</mrow>
</msup>
<mrow>
<mi>n</mi>
<mo>!</mo>
</mrow>
</mfrac>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle G(s)=\prod _{k=1}^{n}G_{k}(s)\ =\ {\frac {s^{\overline {n}}}{n!}}}</annotation>
</semantics>
</math></span><img src="./c6111ad1a5c0934127160c0b67fe82ba0d8dcab1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.005ex; width:24.495ex; height:7.009ex;" alt="{\displaystyle G(s)=\prod _{k=1}^{n}G_{k}(s)\ =\ {\frac {s^{\overline {n}}}{n!}}}" loading="lazy"></span></div>
<p>(using the <a href="Falling_and_rising_factorials" title="Falling and rising factorials">rising factorial</a> notation),
which allows us to recover the product formula for the generating function of the
<a href="Stirling_numbers_of_the_first_kind" title="Stirling numbers of the first kind">Stirling numbers of the first kind</a> (unsigned).
</p>
<div class="mw-heading mw-heading3"><h3 id="The_secretary_problem">The secretary problem</h3></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Secretary_problem" title="Secretary problem">Secretary problem</a></div>
<p>This is an optimal stop problem, a classic in decision theory, statistics and applied probabilities, where a random permutation is gradually revealed through the first elements of its Lehmer code, and where the goal is to stop exactly at the element k such as σ(k)=n, whereas the only available information (the k first values of the Lehmer code) is not sufficient to compute σ(k).
</p><p>In less mathematical words: a series of n applicants are interviewed one after the other. The interviewer must hire the best applicant, but must make his decision (“Hire” or “Not hire”) on the spot, without interviewing the next applicant (and <i>a fortiori</i> without interviewing all applicants).
</p><p>The interviewer thus knows the rank of the k<sup>th</sup> applicant, therefore, at the moment of making his k<sup>th</sup> decision, the interviewer knows only the k first elements of the Lehmer code whereas he would need to know all of them to make a well informed decision.
To determine the optimal strategies (i.e. the strategy maximizing the probability of a win), the statistical properties of the Lehmer code are crucial.
</p><p>Allegedly, <a href="Johannes_Kepler" title="Johannes Kepler">Johannes Kepler</a> clearly exposed this <a href="Secretary_problem" title="Secretary problem">secretary problem</a> to a friend of his at a time when he was trying to make up his mind and choose one out eleven prospective brides as his second wife. His first marriage had been an unhappy one, having been arranged without himself being consulted, and he was thus very concerned that he could reach the right decision.<sup id="cite_ref-ferguson_3-0" class="reference"><a href="#cite_note-ferguson-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Similar_concepts">Similar concepts</h2></div>
<p>Several related constructions have also been put into use. One of them is often called inversion vector, e.g. by <a href="Wolfram_Alpha" class="mw-redirect" title="Wolfram Alpha">Wolfram Alpha</a>.
See also <a href="Inversion_(discrete_mathematics)#Inversion_related_vectors" title="Inversion (discrete mathematics)">Inversion (discrete mathematics) § Inversion related vectors</a>.
</p>
<style data-mw-deduplicate="TemplateStyles:r1266661725">
/* start https://en.wikipedia.org/ */
.mw-parser-output .portalbox{padding:0;margin:0.5em 0;display:table;box-sizing:border-box;max-width:175px;list-style:none}.mw-parser-output .portalborder{border:1px solid var(--border-color-base,#a2a9b1);padding:0.1em;background:var(--background-color-neutral-subtle,#f8f9fa)}.mw-parser-output .portalbox-entry{display:table-row;font-size:85%;line-height:110%;height:1.9em;font-style:italic;font-weight:bold}.mw-parser-output .portalbox-image{display:table-cell;padding:0.2em;vertical-align:middle;text-align:center}.mw-parser-output .portalbox-link{display:table-cell;padding:0.2em 0.2em 0.2em 0.3em;vertical-align:middle}@media(min-width:720px){.mw-parser-output .portalleft{margin:0.5em 1em 0.5em 0}.mw-parser-output .portalright{clear:right;float:right;margin:0.5em 0 0.5em 1em}}
/* end https://en.wikipedia.org/ */
</style>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-lehmer-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-lehmer_1-0">^</a></b></span> <span class="reference-text">
<style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFLehmer1960" class="citation cs2"><a href="D._H._Lehmer" title="D. H. Lehmer">Lehmer, D.H.</a> (1960), "Teaching combinatorial tricks to a computer", <i>Combinatorial Analysis</i>, Proceedings of Symposia in Applied Mathematics, vol. 10, pp. <span class="nowrap">179–</span>193, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1090%2Fpsapm%2F010%2F0113289">10.1090/psapm/010/0113289</a>, <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-8218-1310-2</bdi>, <a href="MR_(identifier)" class="mw-redirect" title="MR (identifier)">MR</a> <a rel="nofollow" class="external text" href="https://mathscinet.ams.org/mathscinet-getitem?mr=0113289">0113289</a></cite> <span class="cs1-hidden-error citation-comment"><code class="cs1-code">{{citation}}</code>: </span><span class="cs1-hidden-error citation-comment">ISBN / Date incompatibility (help)</span></span>
</li>
<li id="cite_note-laisant-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-laisant_2-0">^</a></b></span> <span class="reference-text">
<cite id="CITEREFLaisant1888" class="citation cs2 cs1-prop-foreign-lang-source"><a href="Charles-Ange_Laisant" title="Charles-Ange Laisant">Laisant, Charles-Ange</a> (1888), <a rel="nofollow" class="external text" href="http://www.numdam.org/item?id=BSMF_1888__16__176_0">"Sur la numération factorielle, application aux permutations"</a> [On factorial numbering, application to permutations], <i>Bulletin de la Société Mathématique de France</i> (in French), <b>16</b>: <span class="nowrap">176–</span>183, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.24033%2Fbsmf.378">10.24033/bsmf.378</a></cite></span>
</li>
<li id="cite_note-ferguson-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-ferguson_3-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFFerguson1989" class="citation cs2"><a href="Thomas_S._Ferguson" title="Thomas S. Ferguson">Ferguson, Thomas S.</a> (August 1989), <a rel="nofollow" class="external text" href="https://www2.math.upenn.edu/~ted/210F10/References/Secretary.pdf">"Who solved the secretary problem?"</a> <span class="cs1-format">(PDF)</span>, <i>Statistical Science</i>, <b>4</b> (3): <span class="nowrap">282–</span>289, <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1214%2Fss%2F1177012493">10.1214/ss/1177012493</a></span>, <a href="JSTOR_(identifier)" class="mw-redirect" title="JSTOR (identifier)">JSTOR</a> <a rel="nofollow" class="external text" href="https://www.jstor.org/stable/2245639">2245639</a></cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="Bibliography">Bibliography</h2></div>
<ul><li><cite id="CITEREFMantaciRakotondrajao2001" class="citation cs2">Mantaci, Roberto; Rakotondrajao, Fanja (2001), <a rel="nofollow" class="external text" href="https://web.archive.org/web/20041116061630/http://www.dmtcs.org/volumes/abstracts/pspapers/dm040203.ps">"A permutation representation that knows what "Eulerian" means"</a>, <i>Discrete Mathematics and Theoretical Computer Science</i> (4): <span class="nowrap">101–</span>108, archived from <a rel="nofollow" class="external text" href="http://www.dmtcs.org/volumes/abstracts/pspapers/dm040203.ps">the original</a> on 2004-11-16</cite></li>
<li><cite id="CITEREFKnuth1981" class="citation cs2"><a href="Donald_Knuth" title="Donald Knuth">Knuth, Donald</a> (1981), <i>The Art of Computer Programming</i>, vol. 3, Reading: Addison-Wesley, pp. <span class="nowrap">12–</span>13</cite></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-08-08" href="https://en.wikipedia.org/wiki/?title=Lehmer_code&oldid=1304783060">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>